package com.goldze.mvvmhabit.ui.expandswipe;

import androidx.databinding.ObservableArrayList;
import androidx.databinding.ObservableField;
import androidx.databinding.ObservableList;

import com.goldze.mvvmhabit.widght.expandswipe.ExpandSwipeViewModel;

public class ExpandSwipeChildViewModel<T extends ExpandSwipeViewModel> implements ExpandSwipeViewModel {
    private ExpandSwipeParentViewModel parentViewModel;
    public ObservableList<ExpandSwipeViewModel> list = new ObservableArrayList<>();
    private int index;
    private boolean isPinned;
    private int swipeType;
    public ObservableField<String> text = new ObservableField<>("");

    public ExpandSwipeChildViewModel(ExpandSwipeParentViewModel parentViewModel, int index,String string) {
        this.parentViewModel = parentViewModel;
        this.index = index;
        this.text.set(string);
    }

    public void ininData(){
        list.clear();
        for (int i = 0; i < 5; i++) {
//            KLog.e("sss  "+i);
            ExpandSwipeChildViewModel childViewModel = new ExpandSwipeChildViewModel(parentViewModel,i,"第"+(i+1)+"条");
            list.add(childViewModel);
        }
    }

    @Override
    public ExpandSwipeViewModel getChild(int position) {
        return list.get(position);
    }

    @Override
    public ObservableList<ExpandSwipeViewModel> getItems() {
        return list;
    }

    @Override
    public int getChildCount() {
        return list.size();
    }

    @Override
    public long getId() {
        return index;
    }

    @Override
    public long getChildId(int position) {
        return list.get(position).getId();
    }

    @Override
    public void setPinned(boolean pinned) {
        this.isPinned = pinned;
    }

    @Override
    public boolean isPinned() {
        return isPinned;
    }

    @Override
    public void setSwipeType(int type) {
        this.swipeType = swipeType;
    }

    @Override
    public int getSwipeType() {
        return swipeType;
    }
}
